<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Train extends Model
{
    public $timestamps = false;
    protected $connection = 'xz';
    protected $table = 'train';
    use HasFactory;

    protected $appends = ['is_sign','end_time_exp','start_time_exp'];
    
    /**
     *  获取日期.
     *
     * @param string $value
     * @return string
     */
    public function getCreateTimeAttribute(string $value)
    {
        return Date("Y-m-d",$value);
    }

    public function getStartTimeExpAttribute()
    {
        return Date("Y.m.d",$this->start_time);
    }

    public function getEndTimeExpAttribute()
    {
        return Date("Y.m.d",$this->end_time);
    }

    public function getIsSignAttribute()
    {
        return $this->end_time > time() ? true : false;
    }
}
